From ecc698a282ac69e747026f58ac43eee7958be626 Mon Sep 17 00:00:00 2001 From: Carlos Soriano Date: Thu, 24 Sep 2015 15:54:15 +0200 Subject: [PATCH] gtkplacessidebar: avoid to use a freed string The string we were using is the representation of the internal text in the popover entry. However that can be freed before setting the bookmark label, if i.e. the row is destroyed and therefore the popover as well. To avoid that, duplicate the label in a local variable. One of the consequences is that for those people using development version we migth screwed its bookmarks file, since the bookmark manager wrote garbage from the already freed label. https://bugzilla.gnome.org/show_bug.cgi?id=755215 --- gtk/gtkplacessidebar.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c index 1ed8abe694..2ee7e9e86d 100644 --- a/gtk/gtkplacessidebar.c +++ b/gtk/gtkplacessidebar.c @@ -2397,10 +2397,10 @@ static void do_rename (GtkButton *button, GtkPlacesSidebar *sidebar) { - const gchar *new_text; + gchar *new_text; GFile *file; - new_text = gtk_entry_get_text (GTK_ENTRY (sidebar->rename_entry)); + new_text = g_strdup (gtk_entry_get_text (GTK_ENTRY (sidebar->rename_entry))); file = g_file_new_for_uri (sidebar->rename_uri); if (!_gtk_bookmarks_manager_has_bookmark (sidebar->bookmarks_manager, file)) @@ -2409,6 +2409,7 @@ do_rename (GtkButton *button, _gtk_bookmarks_manager_set_bookmark_label (sidebar->bookmarks_manager, file, new_text, NULL); g_object_unref (file); + g_free (new_text); g_clear_pointer (&sidebar->rename_uri, g_free); -- 2.30.2